#include <os/syscall.h>

long (*syscall[NUM_SYSCALLS])();
extern queue_t ready_queue;
void handle_syscall(regs_context_t *regs, uint64_t interrupt, uint64_t cause)
{
    // syscall[fn](arg1, arg2, arg3, arg4)
    /*if(regs->regs[17]==SYSCALL_EXEC)
    	printk("handle_syscall!\n\r");*/
    regs->sepc = regs->sepc + 4;
    regs->regs[10] = syscall[regs->regs[17]](regs->regs[10],
                                              regs->regs[11],
                                              regs->regs[12],
                                              regs->regs[13]);
    /*if(regs->regs[17]==SYSCALL_EXEC){
    	printk("return from syscall!\n\r");
    	int head_pid = ((pcb_t *)ready_queue.head)->pid;
    	int tail_pid = ((pcb_t *)ready_queue.tail)->pid;
    	printk("head:%d,tail:%d\n\r",head_pid,tail_pid);
    }*/
}
